//
//  ZDBInviteFriendsViewController.m
//  ZDB
//
//  Created by Kk on 2020/3/17.
//  Copyright © 2020 ZDB. All rights reserved.
//

#import "ZDBInviteFriendsViewController.h"
#import "ZDBInviteCodeDetailViewController.h"
#import "ZDBGameViewController.h"

@interface ZDBInviteFriendsViewController ()

@property (weak, nonatomic) IBOutlet UIScrollView *scBgView;
@property (weak, nonatomic) IBOutlet UIButton *yaoqingBtn;

@property (weak, nonatomic) IBOutlet UILabel *allManeyLab;

@property (weak, nonatomic) IBOutlet UILabel *allPeopleLab;

@property (weak, nonatomic) IBOutlet UIButton *lookMareBtn;

@property (weak, nonatomic) IBOutlet UIView *bg1;

@property (weak, nonatomic) IBOutlet UIView *bg2;

@property(nonatomic,strong)NSDictionary * infoDicc;
@property (weak, nonatomic) IBOutlet UILabel *contentLab;

@end

@implementation ZDBInviteFriendsViewController
- (void)viewWillAppear:(BOOL)animated
{
     [self statusBarStyleIsDark:NO];
     [self SetnavigationBarBackgroundImage:RGBA(255, 79, 42, 1) Alpha:1];
     [self SetNavigationBarTitleColor:[UIColor whiteColor]];
}
- (void)viewWillDisappear:(BOOL)animated
{
    [self statusBarStyleIsDark:YES];
    [self SetNavigationBarTitleColor:MAINTITLECOLOR];
    [self SetnavigationBarBackgroundImage:WHITECOLOR Alpha:1];
    [super viewWillDisappear:animated];
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initBackButton:YES];
    KViewRadius(self.bg1, 5);
    KViewRadius(self.bg2, 5);
    self.infoDicc = [NSDictionary dictionary];
    WEAKSELF
    [self.yaoqingBtn add_BtnClickHandler:^(NSInteger tag) {
        STRONGSELFFor(weakSelf);
        if (kStringIsEmpty([strongSelf.infoDicc jsonString:@"shareUrl"])) {
            [JMNotifyView showNotify:@"获取分享地址失败，请返回刷新页面" isSuccessful:NO];
            return;
        }
        ZDBInviteCodeDetailViewController * codeVC = [ZDBInviteCodeDetailViewController new];
        codeVC.title = @"邀请好友";
        codeVC.webUrlStr =[strongSelf.infoDicc jsonString:@"shareUrl"];
        [strongSelf.navigationController pushViewController:codeVC animated:YES];
        
    }];
    
    
    
     [self.lookMareBtn add_BtnClickHandler:^(NSInteger tag) {
        STRONGSELFFor(weakSelf);
         if (weakSelf.is_Pop ==YES) {
             [strongSelf.navigationController popViewControllerAnimated:YES];
             return;
         }
         ZDBGameViewController * tastVC = [[ZDBGameViewController alloc] init];
             tastVC.title = @"我的团队";
        [strongSelf.navigationController pushViewController:tastVC animated:YES];

     }];
    
    
    
    [self refushData];
    
}

-(void)refushData{
    
    //getUserShareInfo
    NSString  * inurl = [[YINetWorkAPIGenerate sharedInstance] APINomark:@"getUserShareInfo"];
    WEAKSELF
    [[SmileHttpTool sharedInstance] POST :inurl parameters:nil origin:NO success:^(NSInteger statusCode, NSString *message, id responseObject) {
      STRONGSELFFor(weakSelf)
        
        if (statusCode==0) {
        NSLog(@"userGoods_getUserGoodsList----%@",responseObject);
            NSDictionary * datadicc = [NSDictionary dictionaryWithDictionary:responseObject];
            strongSelf.infoDicc = datadicc;
            dispatch_async(dispatch_get_main_queue(), ^{
                [strongSelf changeUiData];
            });
            
        }else{
             [JMNotifyView showNotify:message isSuccessful:NO];
        }
          
        // [strongSelf stopLoadingAnimation];
  
    } failure:^(id responseObject, NSError *error) {
        NSLog(@"error----%@",error);
       //  STRONGSELFFor(weakSelf)
        
        [JMNotifyView showNotify:@"网络错误，请重试~" isSuccessful:NO];
        // [self stopLoadingAnimation];
    }];
    
}

-(void)changeUiData{
    
    self.allManeyLab.text = [self.infoDicc jsonString:@"shareMoney"];
    self.allPeopleLab.text = [self.infoDicc jsonString:@"shareCount"];
//    收益=1级返利20%
//        +2级返利15%
//        +3级返利10%
//      +4级返利5%

    NSString * Str1 = [NSString stringWithFormat:@"您的收益 = 1级返利百分之%@",[self.infoDicc jsonString:@"oneReward"]];
    NSString * Str2 = [NSString stringWithFormat:@"    + 2级返利百分之%@",[self.infoDicc jsonString:@"twoReward"]];
    NSString * Str3 = [NSString stringWithFormat:@"    + 3级返利百分之%@",[self.infoDicc jsonString:@"threeReward"]];
    NSString * Str4 = [NSString stringWithFormat:@"   + 4级返利百分之%@",[self.infoDicc jsonString:@"fourReward"]];
    NSString * string = [NSString stringWithFormat:@"%@\n%@\n%@\n%@\n\n",Str1,Str2,Str3,Str4];
    
    NSString * content01 = @"如果您没有通过资质审核，您的下级产生收益的时候您将不会产生收益，请牢记\n\n";
    
    NSString * content02 = @"也就是说您邀请了一个亲朋好友，当他获取任务赏金时，那么您将获得一级返利，当您的好友也邀请了一位好友，该用户完成任务获得了任务赏金时，您将获得二级返利，以此类推，您的收益颇为丰厚\n\n1.邀请您的家人、朋友、同事，邀请的越多，返利就越多\n2.分享到您的微信群、朋友圈，分享的越多，您的返利就越多\n3.禁止刷单或者其他作弊行为，请勿使用刷单工具和第三方刷单平台，否则损失后果自负\n4.本活动的解释权在法律规定范围内归本公司所有";
    
    self.contentLab.text = [NSString stringWithFormat:@"%@%@%@",content01,string,content02];
    
    [UILabel changeLineSpaceForLabel:self.contentLab WithSpace:5];
    
    self.scBgView.contentSize =CGSizeMake(kScreenWidth, 1200);
    
 
    
    
}

//fourReward = 5;
//   oneReward = 20;
//   shareCount = 0;
//   shareMoney = 0;
//   shareUrl = "http://47.240.163.192:8080/web/userShar/index?userCode=1585329682122";
//   systemShareMoney = 1;
//   threeReward = 10;
//   twoReward = 15;
//   userCode = 1585329682122;

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
